#include "game.h"
#include "config.h"
#include "../ui/menu.h"
#include "../model/hero.h"
#include "../ui/text.h"
#include <conio.h> 
#include "../utils/timer.h" 
#include <windows.h> 
void gameLoop() {

	int isover = 0;
	char input = 0;
	int n=0;
	while (!isover) {

		clrscr();

		if(kbhit()) {
			input = getch();
		}
		if(_config.isOpenMap)
			showMapRect();
		if(_config.isOpenShop)
			showShop();
		if(_config.isOpenTipCoin)
			showGameTip(eTipCoin);
		char res = heroCtrl(&player, input);
		//heroCtrl(&enemy,Skill0);
		input = 0;
		if (res == Quit)
			break;

		_hero._show(&player.heros,&enemy.heros);
		sleep_ms(FPS);
		if(enemy.heros.curlife<=0) {
			showMenu(center,"success!press any key to menu");
			getch();
			break;
		}

	}
	// game over
	showGameOver();

}

void startGame(int playertype) {
	initHeros(playertype);
	gameLoop();
}
